/***************************************************************************************************
** WHAT: 	Replication file for the paper
			"More Legislation, More Violence? The Impact of Dodd-Frank in the DRC",
			by Nik Stoop, Marijke Verpoorten, Peter van der Windt.
				
			Below you find the code to regenerate the Tables and Figures,
			presented in the order in which they appear in the Paper and Supplementary files.
			
** WHEN: 	Feb '18

** WHO:	 	Nik Stoop, nik.stoop@kuleuven.be
***************************************************************************************************/


**********************************************************
*** Data sources & Data bases used in this file
********************************************************** 
/* 	Detailed info on the data sources is included in the Paper and Supplementary files
	- Conflict data from ACLED
	- Mining data from IPIS & PV
	- Mineral price data from metalprices.com
	- Rainfall data from CRU
	
	"Dodd-Frank/data/Plos_MLMV_a.dta"
	- This is the restricted database for PV set-up
	- Contains only PV sample of mines
	- Time horizon 2004-2012
	
	"Dodd-Frank/data/Plos_MLMV_b.dta"
	- This is the full database
	- Containing info on all mines (PV sample + IPIS update)
	- Time horizon 2004-2015 */

	
**********************************************************
*** Correction for spatial & serial correlation
********************************************************** 	
/*	Throughout the paper we present results with standard errors that have been corrected
	for spatial and location-specific serial correlation.
	
	We follow the methodology of:
	Conley (1999). GMM estimation with cross sectional dependence. Journal of Econometrics, 92 (1) 1-45.
	
	We use the Stata routine my_reg2hdfespatial.ado, which is available in the supplementary files of:
	Berman et al. (2017). This mine is mine! How minerals fuel conflicts in Africa. American Economic Review, 107 (6).
	
	The routine is based on ols_spatial_HAC.ado, developed by:
	Hsiang, et al. (2011). Civil Conflicts Are Associated with the Global Climate. Nature, 476: 438-41 
	
	and its extension regh2dfespatial.ado, developed by Thiemo Fetzer and based on:
	Guimaraes and Portugal. 2010. A Simple Feasible Alternative Procedure to Estimate Models with High-Dimensional Fixed Effects. Stata Journal 10: 628-49. */
	
	
**********************************************************
*** Set directory
********************************************************** 
clear all
set more off	
cap cd "...set your directory.../"

**********************************************************
*** Table 1: Summary Statistics
**********************************************************

* Time varying variables

	use "data/Plos_MLMV_b",clear	
	* Dodd-frank and conflict indicators
	sum doddfrank looting_i battles_i violence_i riots_i
	
	* Mineral prices
	sum nrmp_gold  nrmp_tin nrmp_tungsten nrmp_tantalum
	
	* rainfall & adjacent conflict
	sum rain_anomaly conflict_adj 
	
* Time invariant variables 
	
	use "data/Plos_MLMV_a",clear
	* mines (PV set-up)
	sum goldterr_t cassterr_t coltterr_t wolfterr_t		
	
	use "data/Plos_MLMV_b",clear
	* mines (full sample)
	sum goldterr_t cassterr_t coltterr_t wolfterr_t	
	
	* wet & dry months
	sum dry wet
	
**********************************************************
*** Figure 1: Maps
**********************************************************
*** This Figure was created using ArcGIS
	
	
**********************************************************
*** Figure 2: World prices of gold and 3T minerals  
**********************************************************		
use "data/Plos_MLMV_b",clear
	
	set scheme s1mono
	twoway (line mp_gold modate, sort), title(Gold,size (medium)) ylabel(, format(%9.0g)) xlabel(528 552 576 600 624 648 671,labsize(medsmall)valuelabels angle(stdarrow)) xtitle(, size(zero)) ytitle(, size(zero)) 
	graph copy Graph a, replace
	twoway (line mp_tin modate, sort), title(Tin,size (medium)) ylabel(, format(%9.0g)) xlabel(528 552 576 600 624 648 671,labsize(medsmall)valuelabels angle(stdarrow)) xtitle(, size(zero)) ytitle(, size(zero))
	graph copy Graph b, replace	
	twoway (line mp_tantalum modate, sort), title(Tantalum,size (medium)) ylabel(, format(%9.0g)) xlabel(528 552 576 600 624 648 671,labsize(medsmall)valuelabels angle(stdarrow)) xtitle(, size(zero)) ytitle(, size(zero))	
	graph copy Graph c, replace	
	twoway (line mp_tungsten modate, sort), title(Tungsten,size (medium)) ylabel(, format(%9.0g)) xlabel(528 552 576 600 624 648 671,labsize(medsmall)valuelabels angle(stdarrow)) xtitle(, size(zero)) ytitle(, size(zero))
	graph copy Graph d, replace
	graph combine a b c d,  scheme(s1color)
	graph save Graph "results/fig2.gph", replace	
	
**********************************************************
*** Figure 3: Monthly conflict events 2004-15
**********************************************************	
	
use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth	
	sort id_3 yrmth	

	gen df_looting=df_terr*nlooting
	gen df_battles=df_terr*nbattles
	gen df_violence=df_terr*nviolence
	gen df_riots=df_terr*nriots

	gen ndf_terr=1-df_terr 
	gen ndf_looting=ndf_terr*nlooting
	gen ndf_battles=ndf_terr*nbattles
	gen ndf_violence=ndf_terr*nviolence
	gen ndf_riots=ndf_terr*nriots

	collapse (sum) df_looting df_battles df_violence df_riots ndf_looting ndf_battles ndf_violence ndf_riots (mean) year df_terr ndf_terr, by(yrmth) 

	set scheme s1mono

	twoway (line df_looting yrmth, sort lcolor(black)), ytitle(" ") xtitle(" ") xline(79) xlabel(1 "1/04" 13 "1/05" 25 "1/06" 37 "1/07" 49 "1/08" 61 "1/09" 73 "1/10" 79 "DF" 85 "1/11" 97 "1/12" 109 "1/13" 121 "1/14" 133 "1/15" 144 "12/15", labsize(small)) title("") subtitle(A. Looting in Policy Region)
	graph copy Graph a, replace
	twoway (line df_battles yrmth, sort lcolor(black)), ytitle(" ") xtitle(" ") xline(79) xlabel(1 "1/04" 13 "1/05" 25 "1/06" 37 "1/07" 49 "1/08" 61 "1/09" 73 "1/10" 79 "DF" 85 "1/11" 97 "1/12" 109 "1/13" 121 "1/14" 133 "1/15" 144 "12/15", labsize(small)) title("") subtitle(C. Battles in Policy Region)
	graph copy Graph c, replace
	twoway (line df_violence yrmth, sort lcolor(black)), ytitle(" ") xtitle(" ") xline(79) xlabel(1 "1/04" 13 "1/05" 25 "1/06" 37 "1/07" 49 "1/08" 61 "1/09" 73 "1/10" 79 "DF" 85 "1/11" 97 "1/12" 109 "1/13" 121 "1/14" 133 "1/15" 144 "12/15", labsize(small)) title("") subtitle(E. Violence in Policy Region)
	graph copy Graph e, replace
	twoway (line df_riots yrmth, sort lcolor(black)), ytitle(" ") xtitle(" ") xline(79) xlabel(1 "1/04" 13 "1/05" 25 "1/06" 37 "1/07" 49 "1/08" 61 "1/09" 73 "1/10" 79 "DF" 85 "1/11" 97 "1/12" 109 "1/13" 121 "1/14" 133 "1/15" 144 "12/15", labsize(small)) title("") subtitle(G. Riots in Policy Region)
	graph copy Graph g, replace

	twoway (line df_looting yrmth, sort lcolor(black) lpattern(dot)) (line ndf_looting yrmth, sort lcolor(black)), ytitle(" ") xtitle(" ") xline(79) xlabel(1 "1/04" 13 "1/05" 25 "1/06" 37 "1/07" 49 "1/08" 61 "1/09" 73 "1/10" 79 "DF" 85 "1/11" 97 "1/12" 109 "1/13" 121 "1/14" 133 "1/15" 144 "12/15", labsize(small)) legend(order(1 "Policy"  2 "Non-Policy") size(small) rows(2)) legend(position(11) ring(0)) title("") subtitle(B. Looting in Policy vs. Non-Policy)
	graph copy Graph b, replace
	twoway (line df_battles yrmth, sort lcolor(black) lpattern(dot)) (line ndf_battles yrmth, sort lcolor(black)), ytitle(" ") xtitle(" ") xline(79) xlabel(1 "1/04" 13 "1/05" 25 "1/06" 37 "1/07" 49 "1/08" 61 "1/09" 73 "1/10" 79 "DF" 85 "1/11" 97 "1/12" 109 "1/13" 121 "1/14" 133 "1/15" 144 "12/15", labsize(small)) legend(order(1 "Policy"  2 "Non-Policy") size(small) rows(2)) legend(position(11) ring(0)) title("") subtitle(D. Battles in Policy vs. Non-Policy)
	graph copy Graph d, replace
	twoway (line df_violence yrmth, sort lcolor(black) lpattern(dot)) (line ndf_violence yrmth, sort lcolor(black)), ytitle(" ") xtitle(" ") xline(79) xlabel(1 "1/04" 13 "1/05" 25 "1/06" 37 "1/07" 49 "1/08" 61 "1/09" 73 "1/10" 79 "DF" 85 "1/11" 97 "1/12" 109 "1/13" 121 "1/14" 133 "1/15" 144 "12/15", labsize(small)) legend(order(1 "Policy"  2 "Non-Policy") size(small) rows(2)) legend(position(11) ring(0)) title("") subtitle(F. Violence in Policy vs. Non-Policy)
	graph copy Graph f, replace
	twoway (line df_riots yrmth, sort lcolor(black) lpattern(dot)) (line ndf_riots yrmth, sort lcolor(black)), ytitle(" ") xtitle(" ") xline(79) xlabel(1 "1/04" 13 "1/05" 25 "1/06" 37 "1/07" 49 "1/08" 61 "1/09" 73 "1/10" 79 "DF" 85 "1/11" 97 "1/12" 109 "1/13" 121 "1/14" 133 "1/15" 144 "12/15", labsize(small)) legend(order(1 "Policy"  2 "Non-Policy") size(small) rows(2)) legend(position(11) ring(0)) title("") subtitle(H. Riots in Policy vs. Non-Policy)
	graph copy Graph h, replace

	graph combine a b c d e f g h, col(2) iscale(*0.75)
	graph save Graph "results/fig3.gph", replace

	
	
*************************************************************************************
*** Main results (presented in Figure 4 in the paper and Tables B,C,D in S4 Appendix)
*************************************************************************************

*** PV set-up
	* restricting time to end of 2012
	* using only P&V data on ASM sites
	use "data/Plos_MLMV_a",clear
	xtset id_3 yrmth
		
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"

	* looting and battles
		eststo clear	 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank `mining',timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableB1.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) 
		
	* violence and riots
		eststo clear		
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank `mining',timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableB2.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) 	


*** More mines
	* restricting time to end of 2012
	* using both IPIS DB update and P&V data on ASM sites

	use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth
	drop if year>2012
		
	* define locals	
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"

	* looting and battles
		eststo clear	 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank `mining',timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableC1.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01)  
		
	* violence and riots
		eststo clear		
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank `mining',timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableC2.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) 
	

*** More mines & Longer time horizon
	* same as above, but extending time horizon to include 2013-2015
	* using both IPIS DB update and P&V data on ASM sites	
	use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth
			
	* define locals	
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"

	* looting and battles
		eststo clear	 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank `mining',timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableD1.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) 
		
	* violence and riots
		eststo clear		
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank `mining',timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000) 
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableD2.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) 
	
	
*********************************************************************
*** Table A in S3 Appendix: Correlation between conflict indicators
*********************************************************************	
		
use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth	
	sort id_3 yrmth
	
	* tetrachoric correlation among conflict indicators
	tetrachoric looting_i battles_i violence_i riots_i,stats(rho p)
	

*********************************************************************
*** Tables B,C,D in S4 Appendix
*********************************************************************	
*** See code for 'Main Results' above

	
*********************************************************************	
*** Table E: Standard errors
*********************************************************************	
*** Test robustness to alternative spatial and temporal specifications in correcting the standard errors

*** PV set-up
	use "data/Plos_MLMV_a",clear
	xtset id_3 yrmth
	
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"
	
	* regs
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg looting_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)

		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg battles_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)

		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg violence_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)

		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg riots_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)
		esttab using "results/tableE1.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_3Tcent_10 df_goldcent_10)

		
*** More mines 
	use "data/Plos_MLMV_b",clear
	drop if year>2012
	xtset id_3 yrmth
	
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"
	
	* regs
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg looting_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)

		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg battles_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)

		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg violence_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)

		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg riots_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)
		esttab using "results/tableE2.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_3Tcent_10 df_goldcent_10)

		
*** More mines & Longer time horizon
	use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth
	
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"
	
	* regs
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg looting_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)

		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg battles_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)

		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg violence_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3)

		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(1000) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(60)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(100) lagcutoff(12)  
		eststo:xi:quietly xtreg riots_i doddfrank  `mining' `prices' `weather' `conflict' i.yrmth, fe cluster(id_3) 
		esttab using "results/tableE3.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_3Tcent_10 df_goldcent_10)

	
*****************************************************************
*** Table F: Including 12-month dynamic and spatial conflict lags
*****************************************************************
			
*** PV set-up
	use "data/Plos_MLMV_a",clear
	xtset id_3 yrmth
	sort id_3 yrmth
	
	* create additional lags
		forvalues v=4(1)12{
		bysort id_3: gen l`v'conflict=conflict[_n-`v']
		}	
		forvalues v=2(1)12{
		bysort id_3: gen l`v'conflict_adj=conflict_adj[_n-`v']
		}	
		*
		
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict l4conflict l5conflict l6conflict l7conflict l8conflict l9conflict l10conflict l11conflict l12conflict conflict_adj l1conflict_adj l2conflict_adj l3conflict_adj l4conflict_adj l5conflict_adj l6conflict_adj l7conflict_adj l8conflict_adj l9conflict_adj l10conflict_adj l11conflict_adj l12conflict_adj"

	* regs
		eststo clear	 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableF1.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep(doddfrank df_3Tcent_10 df_goldcent_10 *conflict*)
				
				
*** More mines // More mines & Longer time horizon
	use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth
	sort id_3 yrmth
	
	* create additional lags
		forvalues v=4(1)12{
		bysort id_3: gen l`v'conflict=conflict[_n-`v']
		}	
		forvalues v=2(1)12{
		bysort id_3: gen l`v'conflict_adj=conflict_adj[_n-`v']
		}	
		*
	
	* define locals	
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict l4conflict l5conflict l6conflict l7conflict l8conflict l9conflict l10conflict l11conflict l12conflict conflict_adj l1conflict_adj l2conflict_adj l3conflict_adj l4conflict_adj l5conflict_adj l6conflict_adj l7conflict_adj l8conflict_adj l9conflict_adj l10conflict_adj l11conflict_adj l12conflict_adj"

	* regs
		eststo clear	 
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict' if year<2013 , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict' if year<2013 , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict' if year<2013 , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict' if year<2013 , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
	
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableF2.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep(doddfrank df_3Tcent_10 df_goldcent_10 *conflict*)
				
			
**********************************************************
*** Table G: Conflict intensity
**********************************************************	
	
*** PV set-up
	use "data/Plos_MLMV_a",clear
	xtset id_3 yrmth
	
	* create nat log of monthly sum of conflict events (add constant of 1 to deal with the zeroes)
		gen ln_looting=ln(nlooting+1)
		gen ln_battles=ln(nbattles+1)
		gen ln_violence=ln(nviolence+1)
		gen ln_riots=ln(nriots+1)
	
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"

	* regs 
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial ln_looting doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial ln_battles doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial ln_violence doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial ln_riots doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableG1.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_3Tcent_10 df_goldcent_10)
		
		
*** More mines // More mines & Longer time horizon
	* use log monthly nr. of conflict events as dependent variables (instead of monthly incidence)
	use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth
		
	* create nat log of monthly sum of conflict events (add constant of 1 to deal with the zeroes)
		gen ln_looting=ln(nlooting+1)
		gen ln_battles=ln(nbattles+1)
		gen ln_violence=ln(nviolence+1)
		gen ln_riots=ln(nriots+1)
	
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"

	* regs 
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial ln_looting doddfrank  `mining' `prices' `weather' `conflict' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial ln_battles doddfrank  `mining' `prices' `weather' `conflict' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial ln_violence doddfrank  `mining' `prices' `weather' `conflict' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial ln_riots doddfrank  `mining' `prices' `weather' `conflict' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		
		eststo:xi:quietly my_reg2hdfespatial ln_looting doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial ln_battles doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial ln_violence doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial ln_riots doddfrank  `mining' `prices' `weather' `conflict', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableG2.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_3Tcent_10 df_goldcent_10)
		


**********************************************************
*** Table H: Combined conflict measure
**********************************************************		

*** PV set-up	
	use "data/Plos_MLMV_a",clear
	xtset id_3 yrmth	
	sort id_3 yrmth
		
	* gen conflict variable that combines all outcomes
		gen allconflict=1 if looting_i==1 | battles_i==1 | violence_i==1 | riots_i==1
		replace allconflict=0 if allconflict!=1
	
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"
		local trends "yrmth79-yrmth150"

	* reg
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial allconflict doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableH1.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_3Tcent_10 df_goldcent_10)
	
	
*** More mines / More mines & longer time horizon	
	use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth	
	sort id_3 yrmth
	
	* gen conflict variable that combines all outcomes
		gen allconflict=1 if looting_i==1 | battles_i==1 | violence_i==1 | riots_i==1
		replace allconflict=0 if allconflict!=1
	
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"
		local trends "yrmth79-yrmth150"

	* regs 
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial allconflict doddfrank  `mining' `prices' `weather' `conflict' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial allconflict doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableH2.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_3Tcent_10 df_goldcent_10)
		
		
**********************************************************
*** Tables I & J: Territory-share of 3T and gold mines
**********************************************************
		
*** PV set-up
	use "data/Plos_MLMV_a",clear
	xtset id_3 yrmth	
	sort id_3 yrmth
	
	* gen share of mining sites
		sum asmterr_t goldterr_t t3terr_t
		bysort yrmth:egen goldtot=total(goldterr_t)
		bysort yrmth:egen t3tot=total(t3terr_t)
		
		gen sgold=goldterr_t/goldtot
		gen st3=t3terr_t/t3tot
	
	* gen interaction DF & mining share
		gen df_sgold=doddfrank*sgold
		gen df_st3=doddfrank*st3
	
	* define locals
		local mining "df_st3 df_sgold"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"

	* regs 
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableJ1.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_st3 df_sgold)

		
*** More mines // More mines & Longer time horizon
	use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth
	sort id_3 yrmth
	
	* gen share of mining sites
		sum asmterr_t goldterr_t t3terr_t
		bysort yrmth:egen goldtot=total(goldterr_t)
		bysort yrmth:egen t3tot=total(t3terr_t)
	
		gen sgold=goldterr_t/goldtot
		gen st3=t3terr_t/t3tot
	
	* Table I: Summary stats on territory-share of mining sites
		bysort id_3:gen x=_n
		sum st3 sgold if df_terr==1 & x==1
		sum st3 sgold if df_terr==0 & x==1
	
	* gen interaction DF & mining share
		gen df_sgold=doddfrank*sgold
		gen df_st3=doddfrank*st3
	
	* define locals
		local mining "df_st3 df_sgold"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"
		local trends "yrmth79-yrmth150"

	* regs 
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict' , timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableJ2.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_st3 df_sgold)
			
	
**********************************************************
*** Table K: territory-specific time trends
**********************************************************		
*** PV set-up	
	use "data/Plos_MLMV_a",clear
	xtset id_3 yrmth	
	sort id_3 yrmth
	
	* gen territory specific time trends (linear)
		browse id_3 year month yrmth
		
		forvalues v=79(1)150{
		gen yrmth`v'=yrmth if id_3==`v'
		replace yrmth`v'=0 if id_3!=`v'
		}
		*		
	
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"
		local trends "yrmth79-yrmth150"

	* regs 
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict' `trends', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict' `trends', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict' `trends', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict' `trends', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableK1.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_3Tcent_10 df_goldcent_10)
		
	
*** More mines // More mines & Longer time horizon
	use "data/Plos_MLMV_b",clear
	xtset id_3 yrmth
	sort id_3 yrmth
	
	* gen territory specific time trends (linear)
		browse id_3 year month yrmth
		
		forvalues v=79(1)150{
		gen yrmth`v'=yrmth if id_3==`v'
		replace yrmth`v'=0 if id_3!=`v'
		}
		*		
	
	* define locals
		local mining "df_3Tcent_10 df_goldcent_10"
		local prices "gold_priceXmine tin_priceXmine tung_priceXmine tant_priceXmine"
		local weather "wet dry rain_anomaly l1rain_anomaly l2rain_anomaly rain_anomaly2 l1rain_anomaly2 l2rain_anomaly2"
		local conflict "l1conflict l2conflict l3conflict conflict_adj l1conflict_adj"
		local trends "yrmth79-yrmth150"

	* regs 
		eststo clear
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict' `trends' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict' `trends' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict' `trends' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict' `trends' if year<2013, timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		
		eststo:xi:quietly my_reg2hdfespatial looting_i doddfrank  `mining' `prices' `weather' `conflict' `trends', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial battles_i doddfrank  `mining' `prices' `weather' `conflict' `trends', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial violence_i doddfrank  `mining' `prices' `weather' `conflict' `trends', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		eststo:xi:quietly my_reg2hdfespatial riots_i doddfrank  `mining' `prices' `weather' `conflict' `trends', timevar(yrmth) panelvar(id_3) lat(point_y) lon(point_x) distcutoff(500) lagcutoff(100000)  
		esttab using "results/tableK2.rtf",replace b(%6.3f) se(%6.3f) star(* 0.1 ** 0.05 *** 0.01) keep (doddfrank df_3Tcent_10 df_goldcent_10)
			
******************************************************************************************************************************************************************************		
******************************************************************************************************************************************************************************		
******************************************************************************************************************************************************************************		

		
